package com.gjy.concurrency.juc;

import org.junit.jupiter.api.Test;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-04-23 08:35:53
 */
public class VolatileTeset {

    private final AtomicInteger ai = new AtomicInteger();

    @Test
    public void test1() {
        ExecutorService pool = Executors.newCachedThreadPool();

        for (int i = 0; i < 100000; i++) {
            pool.execute(ai::getAndIncrement);
        }

        System.out.println("ai.get() = " + ai.get());
    }
}
